package com.adou.d11;

public class RegexTest1 {
    public static void main(String[] args) {
        System.out.println("////////////checkPhone//////////////");
        System.out.println(checkPhone("13000000000"));
        System.out.println(checkPhone("0234-8888888"));
        System.out.println("////////////checkMail//////////////");
        System.out.println(checkMail("用户968@dy.com.cn"));
        System.out.println(checkMail("15501529682@qq.com"));
    }


    public static boolean checkMail(String mail) {
        return mail != null && mail.matches("\\w{2,}@\\w{2,20}(\\.\\w{2,10}){1,2}");
    }

    /**
     * 校验手机号码
     * @param phone
     * @return
     */
    public static boolean checkPhone(String phone){
        return phone !=null && phone.matches("(1[3-9]\\d{9})|(0\\d{2,3}-?[1-9]\\d{4,19})");
    }
}
